extends Control

# class member variables go here, for example:
# var a = 2
# var b = "textvar"
var is_paused = false

func _ready():
	# Called when the node is added to the scene for the first time.
	# Initialization here
	#set_process_unhandled_key_input(true)
	#set_fixed_process(true)
	set_process(true)

func update_pause_status():
		get_tree().paused = is_paused
		visible = is_paused
		if is_paused == true:
			Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		else:
			Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
			
func _process(delta):
	
	#print ("running")
	if Input.is_action_just_pressed("ui_cancel"):
		print ("pause!")
		is_paused = !is_paused
		
		update_pause_status()
		

		
	if Input.is_action_just_pressed("reset"):
		is_paused = false
		update_pause_status()
		
		get_node("/root/global").restartLevel()
		#reset_world()


#func _unhandled_key_input(event):
#	pass

func _on_ResumeGameButton_pressed():
	is_paused = false
	update_pause_status()
	#print ("clicked...")


func _on_RestartGameButton_pressed():
	is_paused = false
	update_pause_status()
		
	get_node("/root/global").restartLevel()


func _on_ExitGameButton_pressed():
	
	is_paused = false
	update_pause_status()
	
	
	get_node("/root/global").changeToCustomScene("res://MainMenu.tscn")
